home *** CD-ROM | disk | FTP | other *** search
/ Varios Español / Varios Español.iso / DBASE5 / CUA_SAMP.ZIP / OPENFILE.PRG < prev    next >
Text File  |  1994-10-12  |  28KB  |  797 lines

  1. PROCEDURE OpenFile
  2. PARAMETER poReturn
  3. *----------------------------------------------------------------------
  4. * DESCRIPTION
  5. *   Driver program for: OpenFile.DFM
  6. *
  7. *   Returns an object that contains the file name, and
  8. *   the action to take.
  9. *   poReturn.FileSpec   - To start.
  10. *           .ShowRadio  - Show the radio buttons
  11. *           .ModText    - Start text for Modify radio button
  12. *           .DoText     - Start text for Do It radio button
  13. *           .TypeArray  - Array with file types in it
  14. *           .TypeStart  - Value of type to start
  15. *           .FormTitle  - Title for the form
  16. *           .FileName   - Name of file selected, <blank> if cancelled
  17. *           .FileMod    - Modify radiobutton selected
  18. *           .DoIt       - Do radiobutton selected
  19. *           .NewName    - Set to .T. if file name doesn't exist already
  20. *           .StrtName   - Default filename, only used if TYPE() = "C"
  21. *           .HelpVal    - HelpID to display when help is selected
  22. *
  23. *----------------------------------------------------------------------
  24. #define cSlash  "\"
  25.  
  26.     PRIVATE cStartSpec, cTypeValue, cArray, nLenMod, nLenDo, nWidth, ;
  27.             lVoid, cDirPath, cFileName
  28.  
  29.     #include "TALKOFF.HDB"
  30.  
  31. #define FN_FULLPATH  0
  32. #define FN_PATH      1
  33. #define FN_FILEROOT  2
  34. #define FN_FILETYPE  3
  35. #define FN_FILENAME  4
  36. #define FN_VALIDFILE 5
  37.  
  38.  
  39.     cStartSpec = poReturn.FileSpec
  40.     cTypeValue = poReturn.TypeStart
  41.  
  42. #include  "OpenFile.DFM"
  43.  
  44.     OpenFile.cWildCard = cStartSpec
  45.  
  46.     OpenFile.Text = poReturn.FormTitle
  47.  
  48.     *------------------------------
  49.     *-- Build the file list listbox
  50.     *------------------------------
  51.     DO BldFile WITH poReturn.FileSpec, OpenFile.lbName3
  52.  
  53.     *--------------------------------------
  54.     *-- Set up the items for the File Types
  55.     *--------------------------------------
  56.     cArray = poReturn.TypeArray
  57.     cAName = m->cArray + "[1]"
  58.     IF TYPE( m->cAName ) = "C"
  59.         OpenFile.cbName5.DataSource = "ARRAY " + m->cArray
  60.     ELSE
  61.         OpenFile.cbName5.DataSource = "STRING " + m->cArray
  62.     ENDIF
  63.  
  64.  
  65.     OpenFile.efName2.Value = LEFT( m->cStartSpec + SPACE(80), 80 )
  66.  
  67.     *--------------------------------------------------
  68.     *-- Start the current directory for reset on return
  69.     *--------------------------------------------------
  70.     cDirStash = SET( "DIRECTORY" )
  71.     OpenFile.txName7.Text = m->cDirStash
  72.     OpenFile.txName7.Width = OpenFile.Width - OpenFile.txName7.Left - 2
  73.     OpenFile.txName7.Height = 1
  74.  
  75.     *------------------------------------------------------------
  76.     *-- Make sure the first item in the list matches the wildcard
  77.     *------------------------------------------------------------
  78.     lExact = SET( "EXACT" ) = "ON"
  79.     SET EXACT OFF
  80.     IF TYPE( m->cAName ) = "C"
  81.         nCurSel = ASCAN( &cArray, m->cTypeValue )
  82.         nCurSel = MAX( 1, m->nCurSel )
  83.         OpenFile.cbName5.CurSel  = m->nCurSel
  84.     ENDIF
  85.     OpenFile.ActiveType = m->cTypeValue
  86.  
  87.     IF m->lExact
  88.         SET EXACT ON
  89.     ENDIF
  90.  
  91.     *---------------------------------------
  92.     *-- Make sure current drive item matches
  93.     *---------------------------------------
  94.     nCurSel = 1
  95.     cLastBar = OpenFile.lbDrives.Value
  96.     cCurDrive = LEFT( SET("DIRECTORY"), 2 )
  97.     DO WHILE .T.
  98.         cThisBar = TRIM( OpenFile.lbDrives.Value )
  99.         IF m->cThisBar == m->cCurDrive
  100.             EXIT
  101.         ENDIF
  102.  
  103.         nCurSel = m->nCurSel + 1
  104.         OpenFile.lbDrives.CurSel = m->nCurSel
  105.         IF OpenFile.lbDrives.Value = m->cLastBar
  106.             EXIT
  107.         ENDIF
  108.     ENDDO
  109.  
  110.  
  111.     *---------------------------
  112.     *-- Build the directory list
  113.     *---------------------------
  114.     DO BldDirs WITH OpenFile.lbName8
  115.  
  116.     IF poReturn.ShowRadio
  117.         OpenFile.rbModify.Text      = poReturn.ModText
  118.         OpenFile.rbDoIt.Text        = poReturn.DoText
  119.  
  120.         nLenMod = poReturn.ModText
  121.         nLenMod = LEN( m->nLenMod )
  122.         nLenDo  = poReturn.DoText
  123.         nLenDo  = LEN( m->nLenDo )
  124.         nWidth  = MAX( m->nLenMod, m->nLenDo ) + 6
  125.  
  126.         OpenFile.rbModify.Width     = m->nWidth
  127.         OpenFile.rbDoIt.Width       = m->nWidth
  128.  
  129.         OpenFile.rbModify.Visible   = .T.
  130.         OpenFile.rbDoIt.Visible     = .T.
  131.  
  132.     ELSE
  133.         OpenFile.rbModify.Enabled   = .F.
  134.         OpenFile.rbDoIt.Enabled     = .F.
  135.     ENDIF
  136.  
  137.     IF TYPE("poReturn.StrtName") = "C"
  138.         OpenFile.efName2.Value = poReturn.StrtName + SPACE(80 - LEN(poReturn.StrtName))
  139.     ENDIF
  140.  
  141.     *---------------------------------------------
  142.     *-- Adjust the HelpId value if .HelpVal is set
  143.     *---------------------------------------------
  144.     IF TYPE( "poReturn.HelpVal" ) = "C"
  145.         OpenFile.pbName13.HelpId = poReturn.HelpVal
  146.         OpenFile.HelpId = poReturn.HelpVal
  147.     ENDIF
  148.  
  149.     lVoid = OpenFile.efName2.SetFocus()
  150.     OpenFile.efName2.SelectAll = .T.
  151.     lVoid = OpenFile.ReadModal()
  152.  
  153.     IF OpenFile.Action
  154.         *-------------------------------------------------
  155.         *-- Make sure the file has a full path designation
  156.         *-------------------------------------------------
  157.         cFileName = LTRIM( TRIM( UPPER( OpenFile.efName2.Value ) ) )
  158.         cFileName = FNAME( m->cFileName, FN_FULLPATH )
  159.  
  160.         poReturn.FileName = m->cFileName
  161.         IF FILE( m->cFileName )
  162.             poReturn.NewName = .F.
  163.         ELSE
  164.             poReturn.NewName = .T.
  165.         ENDIF
  166.  
  167.  
  168.         IF poReturn.ShowRadio
  169.  
  170.             poReturn.FileMod    = OpenFile.rbModify.Value
  171.             poReturn.DoIt       = OpenFile.rbDoIt.Value
  172.  
  173.         ENDIF
  174.  
  175.     ELSE
  176.         poReturn.FileName = ""
  177.     ENDIF
  178.  
  179.     RELEASE albName3, acbName5, albName8, acbName10, lb, lb8
  180.  
  181.     SET DIRECTORY TO &cDirStash
  182.  
  183.     lVoid = OpenFile.Release()
  184.     RELEASE OpenFile
  185.  
  186. RETURN
  187. *-- EOP: OpenFile.prg
  188.  
  189.  
  190. PROCEDURE Valid_OK
  191. *----------------------------------------------------------------------------
  192. * NAME
  193. *   Valid_OK - On Click handler efName2 for File Name prompt
  194. *
  195. *----------------------------------------------------------------------------
  196.     PRIVATE cEditFld, lOk, cTypeFile, cTemp, cFileExt, nDotPos, lExact, ;
  197.             cError, cDirSave, cIntlMsg1, nLastBar
  198.  
  199.     cIntlMsg1 = [Nombre de fichero no válido: ]
  200.  
  201.     oActive = OpenFile.ActiveControl()
  202.     DO CASE
  203.         CASE m->oActive = OpenFile.lbName8
  204.  
  205.             cNewPath = OpenFile.lbName8.Value
  206.             IF UPPER( m->cNewPath ) = "<VACIO>"
  207.                 RETURN
  208.             ENDIF
  209.  
  210.             *-----------------------------------------------
  211.             *-- User selected bar in the Directory list box.
  212.             *-----------------------------------------------
  213.             lExact = SET( "EXACT" ) = "ON"
  214.             SET EXACT ON
  215.  
  216.             cError = ""
  217.             cDirSave = SET( "DIRECTORY" )
  218.  
  219.             DO CASE
  220.                 CASE m->cNewPath = "\"
  221.                     cPath = LEFT( SET( "DIRECTORY" ), 2 ) + "\"
  222.                     ON ERROR cError = MESSAGE()
  223.                     SET DIRECTORY TO &cPath
  224.                     ON ERROR
  225.  
  226.                 CASE m->cNewPath = ".."
  227.                     ON ERROR cError = MESSAGE()
  228.                     SET DIRECTORY TO ..
  229.                     ON ERROR
  230.  
  231.                 OTHERWISE
  232.                     cPath = SET( "DIRECTORY" )
  233.                     IF RIGHT( m->cPath, 1 ) <> "\"
  234.                         cPath = m->cPath + "\"
  235.                     ENDIF
  236.                     cPath = m->cPath + TRIM( m->cNewPath )
  237.                     ON ERROR cError = MESSAGE()
  238.                     SET DIRECTORY TO &cPath
  239.                     ON ERROR
  240.             ENDCASE
  241.  
  242.             IF .NOT. ISBLANK( m->cError )
  243.                 DO ErrorMsg WITH m->cError
  244.                 SET DIRECTORY TO &cDirSave
  245.             ELSE
  246.                 DO UpPostDir
  247.             ENDIF
  248.  
  249.             IF .NOT. m->lExact
  250.                 SET EXACT OFF
  251.             ENDIF
  252.  
  253.         CASE m->oActive = OpenFile.cbName5
  254.             *--------------------------------------------
  255.             *-- User selected bar in the file types list.
  256.             *--------------------------------------------
  257.             cValue = OpenFile.cbName5.Value
  258.             nSpace = AT( " ", m->cValue )
  259.             cFileSpec = LEFT( m->cValue, m->nSpace - 1 )
  260.             OpenFile.ActiveType = m->cFileSpec
  261.  
  262.             OpenFile.efName2.Value = LEFT( m->cFileSpec + SPACE(80), 80 )
  263.             DO BldFile WITH cFileSpec, OpenFile.lbName3
  264.             OpenFile.lbName3.firstTime = .T.
  265.  
  266.             *------------------------------------------------------
  267.             *-- Update the radio button text based on the file type
  268.             *------------------------------------------------------
  269.             IF poReturn.ShowRadio
  270.                 DO UpRadio WITH m->cFileSpec
  271.             ENDIF
  272.  
  273.         CASE oActive = OpenFile.lbDrives
  274.             *-------------------------------
  275.             *-- User selected bar in Drives.
  276.             *-------------------------------
  277.             cCurrent = OpenFile.lbDrives.Value
  278.             cDirSave = SET( "DIRECTORY" )
  279.             lOk = .T.
  280.             ON ERROR lOk = .F.
  281.             SET DIRECTORY TO &cCurrent
  282.             ON ERROR
  283.             IF m->lOk
  284.                 DO UpPostDir
  285.             ELSE
  286.                 SET DIRECTORY TO &cDirSave
  287.                 *-------------------------------
  288.                 *-- Scan for the last drive used
  289.                 *-------------------------------
  290.                 nLastBar = 0
  291.                 OpenFile.lbDrives.Cursel = 1
  292.                 cDirSave = LEFT( m->cDirSave, 2 )
  293.                 DO WHILE OpenFile.lbDrives.Cursel <> m->nLastBar
  294.                     IF m->cDirSave = OpenFile.lbDrives.Value
  295.                         EXIT
  296.                     ENDIF
  297.                     nLastBar = OpenFile.lbDrives.Cursel
  298.                     OpenFile.lbDrives.Cursel = OpenFile.lbDrives.Cursel + 1
  299.                 ENDDO
  300.             ENDIF
  301.  
  302.         OTHERWISE
  303.             lOk = .F.
  304.             cEditFld = LTRIM( TRIM( UPPER( OpenFile.efName2.Value ) ) )
  305.             cEditFld = TRIM( m->cEditFld ) + ""
  306.             cDirSave = SET( "DIRECTORY" )
  307.  
  308.             *-----------------------------------
  309.             *-- Is there a wild card in the name
  310.             *-----------------------------------
  311.             IF "*" $ m->cEditFld .OR. "?" $ m->cEditFld
  312.  
  313.                 *--------------------------------------
  314.                 *-- Adjust the file extension as needed
  315.                 *--------------------------------------
  316.                 nDot = RAT( ".", m->cEditFld )
  317.                 IF nDot > RAT( "\", m->cEditFld )
  318.                     *---------------------------------
  319.                     *-- There is a file extension here
  320.                     *---------------------------------
  321.                     cWildExt = "*." + SUBSTR( m->cEditFld + "   ", m->nDot + 1, 3 )
  322.                     cWildExt = TRIM( UPPER( m->cWildExt ) )
  323.                     IF OpenFile.ActiveType # m->cWildExt
  324.                         *--------------------------------------------------
  325.                         *-- A type change occured.  Scan the File Types for
  326.                         *-- a match.
  327.                         *--------------------------------------------------
  328.                         lExact = SET( "EXACT" ) = "ON"
  329.                         SET EXACT OFF
  330.                         nCurSave = OpenFile.cbName5.CurSel
  331.                         nRow = 1
  332.                         OpenFile.cbName5.CurSel = m->nRow
  333.                         DO WHILE .T.
  334.                             IF OpenFile.cbName5.Value = m->cWildExt
  335.                                 OpenFile.cbName5.CurSel = m->nRow
  336.                                 EXIT
  337.                             ENDIF
  338.                             OpenFile.cbName5.CurSel = m->nRow + 1
  339.                             IF OpenFile.cbName5.CurSel = m->nRow
  340.                                 *----------------------------------------
  341.                                 *-- Restore listbox highlight to original
  342.                                 *----------------------------------------
  343.                                 OpenFile.cbName5.CurSel = m->nCurSave
  344.                                 EXIT
  345.                             ENDIF
  346.                             nRow = m->nRow + 1
  347.                         ENDDO
  348.                         IF m->lExact
  349.                             SET EXACT ON
  350.                         ENDIF
  351.  
  352.                         OpenFile.ActiveType = m->cWildExt
  353.                     ENDIF
  354.                 ENDIF
  355.  
  356.  
  357.                 *----------------------------------------------------
  358.                 *-- If a directory change is in the wild card, try to
  359.                 *-- reposition the directory.
  360.                 *----------------------------------------------------
  361.                 IF "\" $ m->cEditFld .OR. ":" $ m->cEditFld
  362.                     cError = ""
  363.                     DO VerifyDir
  364.                     IF ISBLANK( m->cError )
  365.                         DO UpPostDir
  366.                     ELSE
  367.                         *----------------------------------------------------
  368.                         *-- Display the error message and reset the directory
  369.                         *----------------------------------------------------
  370.                         DO ErrorMsg WITH m->cError
  371.                         SET DIRECTORY TO &cDirSave
  372.                     ENDIF
  373.  
  374.                 ELSE
  375.                     *------------------------------------------------------
  376.                     *-- Build a new file list for the wild card if possible
  377.                     *------------------------------------------------------
  378.                     DO BldFile WITH m->cEditFld, OpenFile.lbName3
  379.                     OpenFile.lbName3.firstTime = .T.
  380.  
  381.                 ENDIF
  382.  
  383.             ELSE
  384.  
  385.                 *-----------------------------------------------
  386.                 *-- Make sure we have a valid file to start with
  387.                 *-----------------------------------------------
  388.                 IF .NOT. ISBLANK( m->cEditFld )
  389.                     lOk = FNAME( m->cEditFld, FN_VALIDFILE )
  390.                 ELSE
  391.                     lOk = .F.
  392.                 ENDIF
  393.  
  394.                 IF lOk
  395.                     *---------------------------
  396.                     *-- Normal file name is here
  397.                     *---------------------------
  398.                     cEditFld = FNAME( m->cEditFld, FN_FULLPATH )
  399.                     cFileExt = FNAME( m->cEditFld, FN_FILETYPE )
  400.  
  401.                     *--------------------------------------------
  402.                     *-- Add on the file extension if not supplied
  403.                     *--------------------------------------------
  404.                     cTypeFile = m->cFileExt
  405.                     nDotPos = RAT( ".", m->cEditFld )
  406.                     IF ISBLANK( m->cFileExt ) .AND.  m->nDotPos # LEN( m->cEditFld )
  407.  
  408.                         *--------------------------
  409.                         *-- Add file extension here
  410.                         *--------------------------
  411.                         cTypeFile = OpenFile.cbName5.Value
  412.                         cTypeFile = TRIM( SUBSTR( m->cTypeFile, 3, 3 ) )
  413.  
  414.                         *----------------------------------------------------
  415.                         *-- If current File Type is not *.*, pull in the type
  416.                         *----------------------------------------------------
  417.                         IF m->cTypeFile <> "*"
  418.                             cTemp = TRIM( m->cEditFld ) + "." + m->cTypeFile
  419.                             cEditFld = m->cTemp
  420.                             OpenFile.efName2.Value = ;
  421.                                               LEFT( m->cEditFld + SPACE(80), 80 )
  422.                         ENDIF
  423.                     ENDIF
  424.                 ENDIF
  425.  
  426.                 *---------------------------------------------------------
  427.                 *-- Set NewName .T. if this is a valid file name that
  428.                 *-- does not exist.
  429.                 *---------------------------------------------------------
  430.                 DO CASE
  431.                     CASE m->lOk .AND.  FILE( m->cEditFld )
  432.                         poReturn.NewName = .F.
  433.                     CASE m->lOk .AND. .NOT.  FILE( m->cEditFld )
  434.                         *------------------------------------------------
  435.                         *-- Make sure the directory exists before setting
  436.                         *------------------------------------------------
  437.                         cError = ""
  438.                         DO VerifyDir
  439.                         IF .NOT. ISBLANK( m->cError )
  440.                             *----------------------------------------
  441.                             *-- Directory doesn't exist, so set error
  442.                             *----------------------------------------
  443.                             DO ErrorMsg WITH m->cError
  444.                             poReturn.NewName = .F.
  445.                             lOk = .F.
  446.                         ELSE
  447.                             poReturn.NewName = .T.
  448.                         ENDIF
  449.                         *------------------------
  450.                         *-- Restore the directory
  451.                         *------------------------
  452.                         SET DIRECTORY TO &cDirSave
  453.  
  454.                     CASE .NOT. m->lOk .AND.  FILE( m->cEditFld )
  455.                         DO ErrorMsg WITH m->cIntlMsg1 + m->cEditFld
  456.                     CASE .NOT. m->lOk .AND. .NOT.  FILE( m->cEditFld )
  457.                         DO ErrorMsg WITH m->cIntlMsg1 + m->cEditFld
  458.                 ENDCASE
  459.  
  460.             ENDIF
  461.  
  462.             IF m->lOk
  463.                 OpenFile.Action = .T.
  464.                 lVoid = OpenFile.Close()
  465.             ENDIF
  466.     ENDCASE
  467.  
  468. RETURN
  469. *-- EOP: Valid_OK
  470.  
  471. PROCEDURE VerifyDir
  472. *----------------------------------------------------------------------------
  473. * NAME
  474. *   VerifyDir - Validate the directory path for the file.  This is a support
  475. *               routine for Valid_OK.  This routine leaves the directory
  476. *               set to the specified one if valid.
  477. *
  478. * VARIABLES
  479. *   cEditFld    = Name of file with path to verify
  480. *   cError      = Set to error message if any
  481. *   cDirSave    = Starting directory
  482. *
  483. *----------------------------------------------------------------------------
  484.     PRIVATE cPath, nPathLen
  485.     *-------------------------------------------
  486.     *-- In case of an error, display the message
  487.     *-------------------------------------------
  488.     cPath = SET( "DIRECTORY" )
  489.  
  490.     ON ERROR cError = MESSAGE()
  491.     cPath = FName( m->cEditFld, 1 )
  492.     ON ERROR
  493.  
  494.     IF .NOT. ISBLANK( cError )
  495.         *-----------------------
  496.         *-- Try the hard way now
  497.         *-----------------------
  498.         cDrv = FileDrv( m->cEditFld )
  499.         cPat = FilePath( m->cEditFld )
  500.         IF .NOT. ISBLANK( cDrv )
  501.             cNewPath = cDrv + ":" + cPat + "n.txt"
  502.         ELSE
  503.             cNewPath = cPat + "n.txt"
  504.         ENDIF
  505.         cError = ""
  506.         ON ERROR cError = MESSAGE()
  507.         cPath = FName( m->cNewPath, 1 )
  508.         ON ERROR
  509.     ENDIF
  510.  
  511.     IF ISBLANK( cError )
  512.         *------------------------------------------------------------
  513.         *-- Chop off the last slash in the path if this is not a root
  514.         *------------------------------------------------------------
  515.         nPathLen = LEN( m->cPath )
  516.         IF m->nPathLen > 3
  517.             cPath = LEFT( m->cPath, m->nPathLen - 1 )
  518.         ENDIF
  519.  
  520.         *---------------------------------------------
  521.         *-- Now, take a shot at changing the directory
  522.         *---------------------------------------------
  523.         cError = ""
  524.         ON ERROR cError = MESSAGE()
  525.         SET DIRECTORY TO &cPath
  526.         ON ERROR
  527.     ENDIF
  528.  
  529.  
  530. RETURN
  531. *-- EOP: VerifyDir
  532.  
  533.  
  534. PROCEDURE UpFile
  535. *----------------------------------------------------------------------------
  536. * NAME
  537. *   UpFile -
  538. *
  539. * DESCRIPTION
  540. *
  541. *----------------------------------------------------------------------------
  542.     PRIVATE cValue, nWidth
  543.  
  544.     IF UPPER( This.Value ) # "<VACIO>"
  545.         cValue = This.Value
  546.         nWidth = This.Width
  547.  
  548.         OpenFile.efName2.Value = LEFT( m->cValue + SPACE(80), 80 )
  549.         OpenFile.efName2.Width = m->nWidth
  550.     ENDIF
  551.  
  552. RETURN
  553. *-- EOP: UpFile
  554.  
  555.  
  556. PROCEDURE ModUpFil
  557. *----------------------------------------------------------------------------
  558. * NAME
  559. *   ModUpFil - OnGotFocus for File list box.
  560. *
  561. *----------------------------------------------------------------------------
  562.     PRIVATE cValue, nWidth
  563.  
  564.     IF This.firstTime .AND. UPPER( This.Value ) # "<VACIO>"
  565.         cValue = This.Value
  566.         nWidth = This.Width
  567.         OpenFile.efName2.Value = LEFT( m->cValue + SPACE(80), 80 )
  568.         OpenFile.efName2.Width = m->nWidth
  569.         This.firstTime = .F.
  570.     ENDIF
  571.  
  572. RETURN
  573. *-- EOP: ModUpFil
  574.  
  575. PROCEDURE TypeLost
  576. *----------------------------------------------------------------------------
  577. * NAME
  578. *   OnLType -
  579. *
  580. * DESCRIPTION
  581. *
  582. *----------------------------------------------------------------------------
  583.  
  584.     cCurrent = This.Value
  585.     cSave    = OpenFile.cWildCard
  586.  
  587.     IF LEFT( m->cCurrent, 5 ) <> LEFT( m->cSave, 5 )
  588.         cValue = This.Value
  589.         nSpace = AT( " ", m->cValue )
  590.         cFileSpec = LEFT( m->cValue, m->nSpace - 1 )
  591.  
  592.         OpenFile.efName2.Value = LEFT( m->cFileSpec + SPACE(80), 80 )
  593.         DO BldFile WITH cFileSpec, OpenFile.lbName3
  594.         OpenFile.lbName3.firstTime = .T.
  595.  
  596.         *------------------------------------------------------
  597.         *-- Update the radio button text based on the file type
  598.         *------------------------------------------------------
  599.         IF poReturn.ShowRadio
  600.             DO UpRadio WITH m->cFileSpec
  601.         ENDIF
  602.     ENDIF
  603.     OpenFile.cWildCard = This.Value
  604.  
  605. RETURN
  606. *-- EOP: TypeLost
  607.  
  608. PROCEDURE TypeGot
  609. *----------------------------------------------------------------------------
  610. * NAME
  611. *   OnGType -
  612. *
  613. * DESCRIPTION
  614. *
  615. *----------------------------------------------------------------------------
  616.     OpenFile.cWildCard = This.Value
  617.  
  618. RETURN
  619. *-- EOP: GotType
  620.  
  621. PROCEDURE ChngType
  622. *----------------------------------------------------------------------------
  623. * NAME
  624. *   ChngType -
  625. *
  626. * DESCRIPTION
  627. *
  628. *----------------------------------------------------------------------------
  629.     cValue = This.Value
  630.     nSpace = AT( " ", m->cValue )
  631.     cFileSpec = LEFT( m->cValue, m->nSpace - 1 )
  632.  
  633.     OpenFile.efName2.Value = LEFT( m->cFileSpec + SPACE(80), 80 )
  634.     DO BldFile WITH cFileSpec, OpenFile.lbName3
  635.  
  636.     *------------------------------------------------------
  637.     *-- Update the radio button text based on the file type
  638.     *------------------------------------------------------
  639.     IF poReturn.ShowRadio
  640.         DO UpRadio WITH m->cFileSpec
  641.     ENDIF
  642.  
  643. RETURN
  644. *-- EOP: ChngType
  645.  
  646. PROCEDURE UpRadio
  647. PARAMETERS poFileSpec
  648. *----------------------------------------------------------------------------
  649. * NAME
  650. *   UpRadio - Update the radio buttons after a change in file spec.
  651. *
  652. * PARAMETERS
  653. *   poFileSpec = Wild card selected.
  654. *
  655. *----------------------------------------------------------------------------
  656.     OpenFile.Draw = .F.
  657.     OpenFile.rbModify.Visible   = .T.
  658.     OpenFile.rbDoIt.Visible     = .T.
  659.     DO CASE
  660.         CASE poFileSpec = "*.PRG"
  661.             OpenFile.rbModify.Text  = [~M~odificar]
  662.             OpenFile.rbModify.Value = .T.
  663.             OpenFile.rbDoIt.Text    = [~E~jecutar]
  664.             OpenFile.rbDoIt.Value   = .F.
  665.         CASE poFileSpec = "*.DBF"
  666.             OpenFile.rbModify.Text  = [~M~odificar]
  667.             OpenFile.rbModify.Value = .F.
  668.             OpenFile.rbDoIt.Text    = [~B~rowse]
  669.             OpenFile.rbDoIt.Value   = .T.
  670.         CASE poFileSpec = "*.FMT"
  671.             OpenFile.rbModify.Text  = [~M~odificar]
  672.             OpenFile.rbModify.Value = .T.
  673.             OpenFile.rbDoIt.Text    = [~D~efinir]
  674.             OpenFile.rbDoIt.Value   = .F.
  675.         CASE poFileSpec = "*.QBE"
  676.             OpenFile.rbModify.Text  = [~M~odificar]
  677.             OpenFile.rbModify.Value = .F.
  678.             OpenFile.rbDoIt.Text    = [~B~rowse]
  679.             OpenFile.rbDoIt.Value   = .T.
  680.         CASE poFileSpec = "*.SCR"
  681.             OpenFile.rbModify.Text  = [~M~odificar]
  682.             OpenFile.rbModify.Value = .T.
  683.             OpenFile.rbDoIt.Text    = [~D~efinir]
  684.             OpenFile.rbDoIt.Value   = .F.
  685.         CASE poFileSpec = "*.FRM"
  686.             OpenFile.rbModify.Text  = [~M~odificar]
  687.             OpenFile.rbModify.Value = .T.
  688.             OpenFile.rbDoIt.Text    = [~E~jecutar]
  689.             OpenFile.rbDoIt.Value   = .F.
  690.         CASE poFileSpec = "*.LBL"
  691.             OpenFile.rbModify.Text  = [~M~odificar]
  692.             OpenFile.rbModify.Value = .T.
  693.             OpenFile.rbDoIt.Text    = [~E~jecutar]
  694.             OpenFile.rbDoIt.Value   = .F.
  695.         CASE poFileSpec = "*.DFM"
  696.             OpenFile.rbModify.Text  = [~M~odificar]
  697.             OpenFile.rbModify.Value = .T.
  698.             OpenFile.rbDoIt.Text    = [~E~jecutar]
  699.             OpenFile.rbDoIt.Value   = .F.
  700.         CASE poFileSpec = "*.PRJ"
  701.             OpenFile.rbModify.Visible   = .F.
  702.             OpenFile.rbModify.Value     = .T.
  703.             OpenFile.rbDoIt.Visible     = .F.
  704.         OTHERWISE
  705.             OpenFile.rbModify.Text  = [~M~odificar]
  706.             OpenFile.rbModify.Value = .T.
  707.             OpenFile.rbDoIt.Text    = [~E~jecutar]
  708.             OpenFile.rbDoIt.Value   = .F.
  709.     ENDCASE
  710.  
  711.     OpenFile.Draw = .T.
  712.     lVoid = OpenFile.efName2.SetFocus()
  713.  
  714. RETURN
  715. *-- EOP: UpRadio WITH poFileSpec
  716.  
  717. PROCEDURE DriveGot
  718. *----------------------------------------------------------------------------
  719. * NAME
  720. *   DriveGot - OnGotFocus handler for lbDrives
  721. *
  722. * DESCRIPTION
  723. *
  724. *----------------------------------------------------------------------------
  725.     OpenFile.cDrive = This.Value
  726.  
  727.  
  728. RETURN
  729. *-- EOP: DriveGot
  730.  
  731. PROCEDURE DriveLost
  732. *----------------------------------------------------------------------------
  733. * NAME
  734. *   DriveLost - OnLostFocus handler for lbDrives
  735. *
  736. * DESCRIPTION
  737. *
  738. *----------------------------------------------------------------------------
  739.     cCurrent = TRIM( This.Value )
  740.     cSave    = TRIM( OpenFile.cDrive )
  741.     IF m->cCurrent <> m->cSave
  742.         cDirSave = SET( "DIRECTORY" )
  743.         lOk = .T.
  744.         ON ERROR lOk = .F.
  745.         SET DIRECTORY TO &cCurrent
  746.         ON ERROR
  747.         IF m->lOk
  748.             DO UpPostDir
  749.         ELSE
  750.             SET DIRECTORY TO &cDirSave
  751.         ENDIF
  752.     ENDIF
  753.     OpenFile.cDrive = m->cCurrent
  754.  
  755. RETURN
  756. *-- EOP: DriveLost
  757.  
  758. PROCEDURE UpPostDir
  759. *----------------------------------------------------------------------------
  760. * NAME
  761. *   UpPostDir - Update lists after a change in directory
  762. *
  763. *----------------------------------------------------------------------------
  764.     PRIVATE cDrive, cLine
  765.  
  766.     OpenFile.Draw = .F.
  767.     OpenFile.txName7.Text = SET( "DIRECTORY" )
  768.     OpenFile.txName7.Width = OpenFile.Width - OpenFile.txName7.Left - 2
  769.     OpenFile.txName7.Height = 1
  770.  
  771.     DO BldDirs WITH OpenFile.lbName8
  772.  
  773.     cFileSpec = OpenFile.ActiveType
  774.  
  775.     OpenFile.efName2.Value = LEFT( m->cFileSpec + SPACE(80), 80 )
  776.     DO BldFile WITH cFileSpec, OpenFile.lbName3
  777.  
  778.     *--------------------------------------------------------
  779.     *-- Scan the drive letter against the drives list box and
  780.     *-- set the highlight.
  781.     *--------------------------------------------------------
  782.     cDrive = LEFT( OpenFile.txName7.Text, 2 )
  783.     cLine = ""
  784.     OpenFile.lbDrives.CurSel = 1
  785.     DO WHILE m->cLine <> OpenFile.lbDrives.Value
  786.         cLine = OpenFile.lbDrives.Value
  787.         IF m->cLine = m->cDrive
  788.             EXIT
  789.         ENDIF
  790.         OpenFile.lbDrives.CurSel = OpenFile.lbDrives.CurSel + 1
  791.     ENDDO
  792.     OpenFile.Draw = .T.
  793.  
  794. RETURN
  795. *-- EOP: UpPostDir
  796.  
  797.